<?php
//1.0 常规方法
/*class Test{
    private  $abc = '';
    public function setAbc($val)
    {
        $this->abc = $val;
    }

    public function getAbc()
    {
        return $this->abc;
    }
}

$test = new Test();
$test->setAbc('abcde');
var_dump($test->getAbc());*/

//2.0 魔术方法 __set设置私有变量 __get获取私有变量
class Test{
    private  $abc = '';
    public function __set($var,$val)
    {
        $this->$var = $val;
    }

    public function __get($var)
    {
        return $this->$var;
    }
}

$test = new Test();
$test->abc = 'asc124';
var_dump($test->abc);

// __isset用于检测私有属性是否存在
class Iss{
    private $dee ='';
    public function __isset($var)
    {
        return isset($this->var) ? true : false;
    }
}
$test = new Iss();
var_dump(isset($test->dee));